﻿using KELT.KELTObjects.ViewportObjectModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace KELT.Animation.Animation2D
{

    public class OpacityDisappearAnimation : IAnimation
    {
        private DoubleAnimation opacityAni;

        public OpacityDisappearAnimation()
        {

            //칼라애니메이션 설정
            opacityAni = new DoubleAnimation();

        }
        public override void SetAnimation(Storyboard myStoryboard, ViewportObj obj)
        {
            animationName = "서서히사라지기";


            opacityAni.Duration = TimeSpan.FromSeconds(endTime - startTime);
            opacityAni.BeginTime = TimeSpan.FromSeconds(startTime);

            opacityAni.From = 1;
            opacityAni.To = 0;


            Storyboard.SetTargetName(opacityAni, AnimationInfo.ANIMATION_ALPHA + obj.getIndexNumber());
            Storyboard.SetTargetProperty(opacityAni, new PropertyPath(SolidColorBrush.OpacityProperty));
            myStoryboard.Children.Add(opacityAni);

        }

        public override void changeAnimation(Storyboard myStoryboard)
        {
            myStoryboard.Children.Remove(opacityAni);

            opacityAni.Duration = TimeSpan.FromSeconds(endTime - startTime);
            opacityAni.BeginTime = TimeSpan.FromSeconds(startTime);
            myStoryboard.Children.Add(opacityAni);
        }

        public override void deleteAnimation(Storyboard myStoryboard)
        {
            myStoryboard.Children.Remove(opacityAni);
        }

    }
}
